<template>
	<view>
		<u-avatar :src="userInfo.avatarUrl" shape="circle" @click="showinfopop"></u-avatar>
		<GetUserInfoChild v-model="popInfoShow" @send="getSonValue"></GetUserInfoChild>
	</view>
</template>

<script>
	import GetUserInfoChild from '../GetUserInfo/GetUserInfoChild.vue'

	export default {
		components: {
			GetUserInfoChild,
		},
		name: "GetUserInfo",
		data() {
			return {
				popInfoShow: false,
				userInfo: {},
			};
		},
		methods: {
			showinfopop(e) {
				this.popInfoShow = true; //弹出自定义授权组件框
			},
			getSonValue(res) {
				this.userInfo = res;
				// this.nickName = res.nickName;
				// this.avatarUrl = res.avatarUrl;
				this.$emit('getUserInfoFn',res);
				//将昵称和头像存在本地，然后组件加载时候判断先从本地取
				uni.setStorageSync('userInfo', res);
			},

		},
		mounted() {
			this.userInfo = uni.getStorageSync('userInfo') || {};//从本地获取userinfo
		}
	}
</script>

<style lang="scss">

</style>
